/*
 *
 *  * Copyright © Yan Zhenjie
 *  *
 *  * Licensed under the Apache License, Version 2.0 (the "License");
 *  * you may not use this file except in compliance with the License.
 *  * You may obtain a copy of the License at
 *  *
 *  *      http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 *
 */
package com.sk.weichat.permission;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.text.TextUtils;


import com.sk.weichat.R;
import com.sk.weichat.view.SelectionFrame;

import java.util.List;


/**
 * Created by YanZhenjie on 2018/1/1.
 */
public final class PermissionSetting {

    private final Context mContext;

    public PermissionSetting(Context context) {
        this.mContext = context;
    }

    public void showSetting(final List<String> permissions) {
        List<String> permissionNames = Permission.transformText(mContext, permissions);
        String message = mContext.getString(R.string.tip_reject_permission_place_holder, TextUtils.join("\n", permissionNames));

        final SettingService settingService = AndPermission.permissionSetting(mContext);
        SelectionFrame mSF = new SelectionFrame(mContext);
        mSF.setSomething(mContext.getString(R.string.dialog_title), message, new SelectionFrame.OnSelectionFrameClickListener() {
            @Override
            public void cancelClick() {
                settingService.cancel();
            }

            @Override
            public void confirmClick() {
                settingService.execute();
            }
        });
        mSF.show();
//        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
//
//        builder .setCancelable(false)
//                .setTitle(R.string.title_dialog)
//                .setMessage(message)
//                .setPositiveButton(R.string.setting, new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        settingService.execute();
//                    }
//                })
//                .setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        settingService.cancel();
//                    }
//                })
//                .show();
    }
}